<template>
  <div class="contSty">
    <template v-for="(item, i) in listData">
      <div :key="i"
           class="cont-bg">
        <el-row :gutter="20"
                class="childLogo">
          <icon-svg icon-name="chaifenyundantiao"
                    class-name="icon-bg" />
          <div class="childTit"
               :title="item.contractNo">
            {{ `拆分运单${i + 1}` }} {{ item.contractNo }}
          </div>
        </el-row>
        <el-row :gutter="20"
                class="childItem line-herger14">
          <el-col :span="10"
                  class="shipSty">
            <div class="line-herger14">
              <icon-svg icon-name="qidian_jiedian"
                        class-name="icon-1" />
              {{ item.customer.customerName }}<br />
              <p class="fontSty-4">
                发货地址：{{ item.fromAddress.province
                    }}{{ item.fromAddress.district }}{{ item.fromAddress.city
                    }}{{ item.fromAddress.address }}
              </p>
              <p class="fontSty-4">
                联系方式：{{ item.fromContact.contactName }}
                {{ item.fromContact.contactMobile }}
              </p>
              <p class="fontSty-4">发货时间：{{ item.fromTime }}</p>
            </div>
          </el-col>
          <el-col :span="10"
                  class="shipSty">
            <div class="line-herger14">
              <icon-svg icon-name="zhongdian_jiedian"
                        class-name="icon-1" />
              {{ item.consignee.consigneeName }}<br />
              <p class="fontSty-4">
                收货地址：{{ item.toAddress.province
                    }}{{ item.toAddress.district }}{{ item.toAddress.city
                    }}{{ item.toAddress.address }}
              </p>
              <p class="fontSty-4">
                联系方式：{{ item.toContact.contactName }}
                {{ item.toContact.contactMobile }}
              </p>
              <p class="fontSty-4">收货时间：{{ item.toTime }}</p>
            </div>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="5"
                  class="fontSty-1">
            总数量(件)：{{ item.waybillCache.totalQuantity }}
          </el-col>
          <el-col :span="5"
                  class="fontSty-1">
            总重量(公斤)：{{ item.waybillCache.totalWeight }}
          </el-col>
          <el-col :span="5"
                  class="fontSty-1">
            总体积(方)：{{ item.waybillCache.totalVolume }}
          </el-col>
        </el-row>
      </div>
    </template>
  </div>
</template>

<script>
import { transport } from "@/api/index";
export default {
  name: "SplitWaybill",
  props: {
    row: {
      type: Object,
      default: () => { }
    },
    paramsData: {
      type: Object,
      default: () => { }
    }
  },
  data () {
    return {
      listData: [],
      dialogVisible: false
    };
  },
  computed: {
    waybillId () {
      return this.paramsData?.waybillId || this.paramsData?.id
    }
  },
  watch: {
    waybillId () {
      this.getDivideWayBill();
    }
  },
  mounted () {
    this.getDivideWayBill();
  },
  methods: {
    // 拆单详情
    async getDivideWayBill () {
      const { code, data } = await transport.getDivideWaybillDetail(this.waybillId);
      if (code !== 0) return;
      this.listData = data.childs;
      if (this.listData.length) {
        this.dialogVisible = true;
      } else {
        this.$message.error('暂无数据')
      }
    }
  }
};
</script>
<style lang="scss" scoped>
.flex-code-box {
  display: flex;
}
.contSty {
  min-height: 200px;
  max-height: 408px;
  overflow-x: hidden;
}
.cont-bg {
  background: #fafafa;
  margin-top: 5px;
  margin-left: 5px;
}
.icon-bg {
  width: 210px !important;
  height: 30px;
  position: absolute;
  top: 0;
  margin: 0;
}
.childTit {
  width: 210px !important;
  height: 30px;
  position: absolute;
  left: 5px;
  top: 5px;
  margin: 0;
  color: var(--prev-bg-white);
  overflow: hidden; //超出的文本隐藏
  text-overflow: ellipsis; //溢出用省略号显示
  white-space: nowrap; // 默认不换行；
}
.childLogo {
  height: 30px;
  margin: 0 !important;
}
.childItem {
  padding-top: 15px;
  margin-bottom: 16px !important;
}
.line-herger14 {
  line-height: 14px;
}
.iconsty {
  width: 14px;
  height: 14px;
  margin-left: 5px;
}
.icon-1 {
  width: 24px;
  height: 24px;
  position: absolute;
  left: -20px;
  top: -2px;
}
.shipSty {
  position: relative;
  padding: 0 0px;
  margin-left: 60px;
}
.link-box {
  display: flex;
  align-items: center;
}

.linkClass {
  max-width: 260px !important;
  color: var(--prev-color-primary) !important;
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  // width: 100px !important;
  // color: var(--prev-color-primary) !important;
  // display: block;
  // overflow: hidden;
  // white-space: nowrap;
  // text-overflow: ellipsis;
  // text-align: center;
}
.iconClass {
  margin-left: 2px;
  margin-top: 3px;
  width: 16px;
  height: 16px;
  cursor: pointer;
  color: chocolate;
}
.fontSty-4 {
  word-break: break-all;
  white-space: pre-wrap;
  line-height: 20px;
}
</style>
